package cqut.gbq.qimo.controller;

import cqut.gbq.qimo.entity.Course;
import cqut.gbq.qimo.entity.ResBean;
import cqut.gbq.qimo.entity.Student;
import cqut.gbq.qimo.entity.Teacher;
import cqut.gbq.qimo.service.CourseService;
import cqut.gbq.qimo.service.TeacherService;
import cqut.gbq.qimo.utils.GenerateCourseCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName TeacherController
 * @Description TODO
 * @Author guobenqi
 * @Date 2021/6/20 23:46
 */

@Api(tags = "老师相关接口")
@RestController
public class TeacherController {

    @Autowired
    TeacherService teacherService;

    @ApiOperation("根据tid查询老师信息")
    @GetMapping("/getTeacherByTid")
    private ResBean getTeacherByTid(Integer tid){
        Teacher teacher = teacherService.getTeacherByTid(tid);
        if (teacher != null){
            return ResBean.success("查询成功",teacher);
        } else {
            return ResBean.error("查询失败");
        }
    }

    @ApiOperation("根据tid查询未交的作业数量")
    @GetMapping("/getNotSubmit")
    private ResBean getNotSubmit(@RequestParam Integer tid){
        Integer number = teacherService.getNotSubmit(tid);
        if (number != null){
            return ResBean.success("查询成功",number);
        } else {
            return ResBean.error("查询失败");
        }
    }

    @ApiOperation("根据tid查询未检查的作业数量")
    @GetMapping("/getNotCheck")
    private ResBean getNotCheck(@RequestParam Integer tid){
        Integer number = teacherService.getNotCheck(tid);
        if (number != null){
            return ResBean.success("查询成功",number);
        } else {
            return ResBean.error("查询失败");
        }
    }

    @ApiOperation("根据tid查询已检查的作业数量")
    @GetMapping("/getCheck")
    private ResBean getCheck(@RequestParam Integer tid){
        Integer number = teacherService.getCheck(tid);
        if (number != null){
            return ResBean.success("查询成功",number);
        } else {
            return ResBean.error("查询失败");
        }
    }

    @ApiOperation("修改老师的信息")
    @PostMapping("/editTeacher")
    private ResBean editTeacher(@RequestBody Teacher teacher){
        System.out.println(teacher);

        return teacherService.editTeacher(teacher);
    }


}
